#ifndef __PG_DBCONNECTION_MFARM_H_
#define __PG_DBCONNECTION_MFARM_H_

#include "Farm.h"
/*
 * demand read and persistant write
 */

class MFarm : public Farm
{
	public:
		MFarm(DbParam dbParameters, const char *writers, const char *readers, bool debug = false); 
		PGconn *GetReader();
		PGconn *GetWriter(int idx);
		int GetWriterSize() { return writers_.size(); }
		void CloseConnection(PGconn *c, bool write = false);
                void Print();
		~MFarm() {}
	protected:
		bool initilize(const char *readers,const char *writers);
		PGconn *getNextReader(int &num, int size);
		void closeAll();
		vector < DbHost * > readers_;
		vector < PDbHost * > writers_;
};

#endif
